package com.example.devices.adapter

import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.device.R
import com.example.devices.entity.OrderEntity

class OrderAdapter:BaseQuickAdapter<OrderEntity,BaseViewHolder>(R.layout.item_order) {
    override fun convert(holder: BaseViewHolder, item: OrderEntity) {
        val orderType = holder.getView<TextView>(R.id.order_type)
        val orderAddress = holder.getView<TextView>(R.id.order_address)
        val orderTime = holder.getView<TextView>(R.id.order_time)
        val orderStatus = holder.getView<TextView>(R.id.order_status)
        orderType.text = item.orderType
        orderAddress.text = item.address
        orderTime.text = item.appointmentTime.substring(0,10)
        orderStatus.text = item.status
        if(item.status == "新建"){
            orderStatus.setBackgroundResource(com.example.resource.R.drawable.bg_item_devices_green)
        }else if(item.status == "已完成"){
            orderStatus.setBackgroundResource(com.example.resource.R.drawable.bg_item_devices_red)
        }else if(item.status == "已转派"){
            orderStatus.setBackgroundResource(com.example.resource.R.drawable.bg_item_devices)
        }else{
            orderStatus.setBackgroundResource(com.example.resource.R.drawable.bg_item_devices_blue)
        }
    }
}